package com.py.custom.common.web.utils;


import com.py.custom.common.web.enums.ResponseEnums;
import com.py.custom.common.web.response.BaseResponse;

import static com.py.custom.common.web.enums.ResponseEnums.FAIL;
import static com.py.custom.common.web.enums.ResponseEnums.SUCCESS;


/**
 * description： 统一返回工具类
 *
 * @author pengyou
 * @version 1.0.0
 * @date 2021/10/17
 */
public class ResponseUtils {

    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(SUCCESS, data);
    }

    public static <T> BaseResponse<T> success(ResponseEnums responseEnums, T data) {
        return new BaseResponse<>(responseEnums, data);
    }

    public static <T> BaseResponse<T> success(ResponseEnums responseEnums, String msg, T data) {
        return new BaseResponse<>(responseEnums, msg, data);
    }

    public static <T> BaseResponse<T> fail(T data) {
        return new BaseResponse<>(FAIL, data);
    }

    public static <T> BaseResponse<T> fail(ResponseEnums responseEnums, T data) {
        return new BaseResponse<>(responseEnums, data);
    }

    public static <T> BaseResponse<T> fail(ResponseEnums responseEnums, String errorMsg, T data) {
        return new BaseResponse<>(responseEnums, errorMsg, data);
    }
}
